/*
 * Description: 测试ModalPro
 * Author: wangyifei
 * DateCreated: 2024-03-04 11:03
 */

import ModalPro from '@/components/ModalPro';
import { Button, Form, Input, Space } from 'antd';
import { selectTestForm } from '@/service/test';

function foo(num1: number, num2: string) {
	return num1 + num2;
}

type FooParams = Parameters<typeof foo>;

const ModalProView = () => {
	const [modal] = ModalPro.useModal();
	const [form] = Form.useForm<{ title: string }>();

	return (
		<>
			<Button type="primary" onClick={() => modal.setModal(true, '新建', { name: 'frank' })}>
				open
			</Button>
			<ModalPro
				modal={modal}
				width={1000}
				request={selectTestForm}
				fetchRequest={() => {
					const formData = form.getFieldsValue();
					// const { code, data } = await selectTestForm(formData);
					// form.resetFields();
					return [formData, 'aaa'];
				}}
				onSuccess={({ data }) => {
					console.log('提交成功！！！！', data);
				}}
				onError={() => {
					console.log('提交失败-------');
				}}
				content={
					<Form form={form}>
						<Form.Item label="标题" name="title">
							<Input placeholder="请输入" />
						</Form.Item>
					</Form>
				}
				extendBtns={
					<Space>
						<Button
							type="primary"
							onClick={() => {
								modal.setModal(false);
							}}
						>
							扩展按钮
						</Button>
					</Space>
				}
			/>
		</>
	);
};

export default ModalProView;
